package com.hm.hw1221;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;


@Controller
@RequestMapping("cars")
@SessionAttributes(names= {"cars"},types= {ArrayList.class})
public class Car2Controller {
	private static List<Car> cars = new ArrayList<>();

	{
		cars.add(new Car(2800000.0,"宝马X5",30.0,8,"银灰色"));
		cars.add(new Car(2500000.0, "宝马X4",25.0,8,"红色"));
		cars.add(new Car(1800000.0, "宝马基础款",18.0,6,"黑色"));
	}
	@GetMapping("all")
	public String findAll(Map<String, Object> map) {
		map.put("cars", cars);
		return "car/cars";
	}
	
}
